package manage.controller;

import core.controller.BaseController;
import core.domain.ListDataInfo;
import core.domain.Result;
import lombok.extern.slf4j.Slf4j;
import manage.domain.user.dto.UserQueryDTO;
import manage.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@Slf4j
@RestController
@RequestMapping("/user")
public class UserController extends BaseController {
    @Autowired
    private IUserService userService;

    @GetMapping("/list")
    public ListDataInfo list(UserQueryDTO userQueryDTO) {
        log.info("UserController -> list : {}", userQueryDTO);
        return toListDataInfo(userService.list(userQueryDTO));
    }

    @PutMapping("/updateStatus")
    //TODO 拉黑、解封 限制用户操作
    public Result<Void> updateStatus(Long userId, Integer status) {
        log.info("UserController -> updateStatus : {}, {}", userId, status);
        int result = userService.updateStatus(userId, status);
        return toResult(result);
    }
}